package com.sptus.system.domain;

import com.sptus.common.core.redis.RedisCache;
import com.sptus.common.utils.StringUtils;
import com.sptus.system.service.ISptDevLogService;
import com.sptus.system.service.impl.WorkOrdersServiceImpl;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class BBWS {
    //总体过压告警状态
    String overallOvervoltageAlarmState;

    //总体欠压告警状态
    String overallUnderovervoltageAlarmState;
    //单体过压告警状态
    String cellOvervoltageAlarmState;
    //单体欠压告警状态
    String cellUnderovervoltageAlarmState;

    //充电电流告警状态
    String chargingCurrentAlarmState;

    //放电电流告警状态
    String disChargingCurrentAlarmState;
    //总体充电温度告警状态
    String overallChargingTemperatureAlarmState;

    //总体放电温度告警状态
    String overallDischargingTemperatureAlarmState;
    //电芯充电温度告警状态
    String batteryChargingTemperatureAlarmState;

    //电芯放电温度告警状态
    String batteryDisChargingTemperatureAlarmState;
    //MOS温度告警状态
    String MOSTemperatureAlarmState;
    public BBWS(String bbws){
        if (!StringUtils.isEmpty(bbws)){
            String[] bbwsArr= bbws.split(";");
            this.overallOvervoltageAlarmState = bbwsArr[0];
            this.overallUnderovervoltageAlarmState = bbwsArr[1];
            this.cellOvervoltageAlarmState = bbwsArr[2];
            this.cellUnderovervoltageAlarmState = bbwsArr[3];
            this.chargingCurrentAlarmState = bbwsArr[4];
            this.disChargingCurrentAlarmState = bbwsArr[5];
            this.overallChargingTemperatureAlarmState = bbwsArr[6];
            this.overallDischargingTemperatureAlarmState = bbwsArr[7];
            this.batteryChargingTemperatureAlarmState = bbwsArr[8];
            this.batteryDisChargingTemperatureAlarmState = bbwsArr[9];
            this.MOSTemperatureAlarmState = bbwsArr[10];
        }
    }

    public void createAlarm(String sn, String string, BBWS bbws, ISptDevLogService   sptDevLogService, WorkOrdersServiceImpl service, RedisCache redisCache){
        sptDevLogService.saveDevAlarm(sn,bbws,service,redisCache);
    }
}
